<%= stylesheet_link_tag "basic_info" %>
<%= stylesheet_link_tag "users" %>

<div id="notice" class="notice"><%= notice %></div>

<div class="web-title">
  <span>用户详细资料</span>
</div>

<div class="edit-tabs">
  <a id="user_tab" class="edit-tab  inline-block tab-selected" href="###">
    <%= t '.title' %>
  </a>
</div>

<div class="right_btn_div">
  <%= link_to (t 'common.edit'), edit_user_path(@user), {:class => "inline-block s-btn"} %>
  <%= link_to (t 'common.back'), users_path, {:class => "inline-block s-btn"} %>
</div>

<div id="user_info">
  <table class="show_t">
    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.login'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.login}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>
    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.biz_unit'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.biz_unit.name}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>
    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.role'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.role.name}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>
    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.email'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.email}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>
    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.comment'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.comment }", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>
    <tr>
      <td></td>
      <td class="show_align_left ellipsis"><a href="###" id="show_more_info">详细</a></td>
    </tr>
    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.login_count'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.login_count}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>

    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.failed_login_count'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.failed_login_count}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>

    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.last_request_at'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.last_request_at}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>

    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.current_login_at'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.current_login_at}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>

    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.last_login_at'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.last_login_at}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>

    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.current_login_ip'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.current_login_ip}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>

    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.last_login_ip'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.last_login_ip}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>
    <tr>
      <td><%= label_tag (t 'activerecord.attributes.user.updated_at'), nil, :class => "show_align_right" %></td>
      <td>
        <%= label_tag "#{@user.updated_at}", nil, :class => "show_align_left ellipsis" %>
      </td>
    </tr>
  </table>
</div>


<script type="text/javascript">

    $("#user_tab").click(function() {
        show_user_info();
        return false;
    });
    $("#show_more_info").parent().parent().nextAll().hide();
    var user_info = "less"; // 用户信息的当前状态，简略模式
    $("#show_more_info").click(function(){
        if (user_info == "more") {
            user_info = "less";
            $(this).html("详细");
            $(this).parent().parent().nextAll().hide();
        } else {
            user_info = "more";
            $(this).html("简略");
            $(this).parent().parent().nextAll().show();
        }
    });

    function show_user_info() {
        $(".tab-selected").removeClass("tab-selected");
        $("#user_tab").addClass("tab-selected");
        $("#user_info").show();
    }
</script>
